import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { GameCtrl } from './GameCtrl';
const { ccclass, property } = _decorator;

@ccclass('Pipe')
export class Pipe extends Component {
    private moveSpeed: number = 100

    onLoad() {
        this.moveSpeed = GameCtrl.instance.moveSpeed - 20
    }

    update(deltaTime: number) {
        const distance = this.moveSpeed * deltaTime

        const pos = this.node.position
        this.node.setPosition(pos.x - distance, pos.y)
        if (pos.x < -800) this.node.destroy()
    }
}


